0806 568 6953, 0813 593 3718

Difference between Functions(FC) and Function Blocks(FB) in Siemens PLC Programming

This article highlights the difference between functions and function blocks in Siemens PLC programming.

Functions

A function (FC) is a code block without memory. A function gives you the option to transfer parameters in the user program. Functions are therefore particularly suitable for frequently recurring complex constructs. You have no instance data memory in which values of block parameters can be stored. Therefore, when an FC is called, all formal parameters (such as defined under In, Out, In-Out) cannot be left blank and must be assigned actual parameters.

Functions can use global data blocks (A data block is used to store user data. There are global data blocks that can be accessed by all code blocks and instance data blocks that are assigned to a specific FB call.) to store data permanently.

A function contains a program that is executed when the function is called by another code block. Functions can be used, for example, for the following purposes:

  • To return function values to the calling block, e.g. for mathematical functions
  • To execute technological functions, e.g. individual controls using bit logic operations
  • A function can be called several times at different points in a program. As a result, they simplify programming of frequently recurring functions.

    Function Blocks

    Function blocks are code blocks that store their input, output and in-out parameters permanently in instance data blocks, so that they remain available even after the block has been executed. Therefore, they are also referred to as blocks “with memory”.

    Like a function, a function block contains subroutines that are always executed when a function block is called by another code block. A function block can also be called several times at different points in a program. When an FB is called the formal parameters can be left with no address.

    A call of a function block is referred to as an instance. An instance data block is required for each instance of a function block; it contains instance-specific values for the formal parameters declared in the function block. The function block can store its instance-specific data in its own instance data block or in the instance data block of the calling block.

    FUNCTIONS (FCs) FUNCTION BLOCKS (FBs)
    Has no dedicated memory Has dedicated memory
    Parameters cannot be left blank Parameters can be left with no address
    Requires no instance data blank Needs an instance data block to work

    Differences between FCs and FBss

    An example of function vs function block operation is shown in the video below.